<layout-header></layout-header>

<nav class="container-xl mb-3">
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a routerLink="/welcome">首页</a></li>
        <li class="breadcrumb-item active">全局配置</li>
    </ol>
</nav>

<div class="container-xl mb-3">
    <div class="text-end mb-3">
        <button class="btn btn-primary" [routerLink]="['/setting/create']">添加</button>
    </div>

    <table class="table table-hover align-middle">
        <thead class="table-light">
            <tr>
                <th scope="col">#</th>
                <th scope="col">名称</th>
                <th scope="col" class="d-none d-lg-table-cell">类型</th>
                <th scope="col" class="d-none d-xl-table-cell">键名</th>
                <th scope="col">键值</th>
                <th scope="col" class="d-none d-xxl-table-cell">备注</th>
                <th scope="col">操作</th>
            </tr>
        </thead>
        <tbody>
            @for (item of settings; track item.rd) {
            <tr>
                <th scope="row">{{item.rd}}</th>
                <td>{{item.title}}</td>
                <td class="d-none d-lg-table-cell">
                    {{fieldTypes[item.type] && fieldTypes[item.type].name || '-'}}
                </td>
                <td class="d-none d-xl-table-cell">{{item.name}}</td>
                <td class="w-max150 text-truncate">{{item.value}}</td>
                <td class="d-none d-xxl-table-cell w-max150 text-truncate">{{item.remark}}</td>
                <td class="text-nowrap">
                    <button class="btn btn-sm btn-primary me-2" routerLink="/setting/update/{{item.rd}}">编辑</button>
                    <button class="btn btn-sm btn-danger me-2" (click)="deleteSetting(item)" [disabled]="item.group == 'bot'">删除</button>
                </td>
            </tr>
            }
        </tbody>
    </table>
</div>